package net.slidinglive.utilities.model;

import android.database.Cursor;
import android.provider.ContactsContract;

/**
 * @author Sebastian Hoffmann <bo.hoffi@gmail.com>
 */
public class EmailAddress {

    private String address;
    private int type;

    public EmailAddress() {

    }

    public EmailAddress(final Cursor emailAddressCursor) {

        this.setAddress(emailAddressCursor.getString(emailAddressCursor
                .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)));
        this.setType(emailAddressCursor.getInt(emailAddressCursor
                .getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE)));
    }

    /**
     * @return the address
     */
    public String getAddress() {

        return this.address;
    }

    /**
     * @param address
     *            the address to set
     */
    public void setAddress(String address) {

        this.address = address;
    }

    /**
     * @return the type
     */
    public int getType() {

        return this.type;
    }

    /**
     * @param type
     *            the type to set
     */
    public void setType(int type) {

        this.type = type;
    }

    /**
     * @return the resource id of the type label
     */
    public int getTypeLabelResourceId() {

        return ContactsContract.CommonDataKinds.Email.getTypeLabelResource(this.getType());
    }
}